#include <stdio.h>
#include <memory.h>

static int input_number()
{
    int n;
    char line[20];
    fgets(line, sizeof(line), stdin);
    sscanf(line, "%d", &n);
    return n;
}

static int tree[100000][11]; /* prefix tree */
static int num_nodes;

int main()
{
    int t, T = input_number();
    memset(tree, 0, sizeof(tree));
    for (t = 0; t < T; t++)
    {
        int i, n = input_number(), conflict = 0;
        num_nodes = 0;
        for (i = 0; i < n; i++)
        {
            int k, j, c, prev_num_nodes = num_nodes;
            char line[20];
            fgets(line, sizeof(line), stdin);
            if (conflict)
                continue;

            k = 0;
            for (j = 0; (c = line[j]) && c != '\n'; j++)
            {
                c = c - '0' + 1;
                if (tree[k][c] == 0)
                    tree[k][c] = ++num_nodes;
                k = tree[k][c];
                if (tree[k][0]) /* some other string ends here */
                {
                    conflict = 1;
                    break;
                }
            }
            tree[k][0] = -1; /* mark $ */
            if (num_nodes == prev_num_nodes)
                conflict = 1;
        }
        printf("%s\n", conflict ? "NO" : "YES");
        memset(tree, 0, (num_nodes + 1) * sizeof(tree[0]));
    }
    return 0;
}
